<template>
	<view class="content">
		<view>
			<view class="">
				<!-- 所有内容的容器 -->
				<my-index v-if="current == 0"></my-index>
				<my-work v-if="current == 1"></my-work>
				<my-user v-if="current == 2"></my-user>
			</view>
			<!-- 与包裹页面所有内容的元素u-page同级，且在它的下方 -->
			<u-tabbar v-model="current" :list="list" active-color="#36B278" inactive-color="#545454" :mid-button="false"
				@change="switchBar"></u-tabbar>
		</view>

	</view>
</template>

<script>
	import {
		getInfo
	} from '@/api/index.js'
	export default {
		// props:{
		// 	current:{
		// 		default:2,
		// 		required:false,
		// 		type:Boolean
		// 	}
		// },
		data() {
			return {
				list: '',
				current: 2
			}
		},
		onLoad(params) {
			//console.log(params);
			this.init(params)
		},
		methods: {
			init(params) {
				if (params.to !== undefined) {
					this.current = params.to
				}
				this.list = [{
						iconPath: require('@/static/icon/tab_bar_home@2x.png'),
						selectedIconPath: require('@/static/icon/tab_bar_home_fill@2x.png'),
						text: '首页',
						//count: 2,
						//isDot: true,
						customIcon: false
					},
					{
						iconPath: require('@/static/icon/tab_bar_workbench@2x.png'),
						selectedIconPath: require('@/static/icon/tab_bar_workbench_fill@2x.png'),
						text: '工作台',
						//count: 23,
						isDot: false,
						customIcon: false
					},
					{
						iconPath: require('@/static/icon/tab_bar_my@2x.png'),
						selectedIconPath: require('@/static/icon/tab_nar_my_fill@2x.png'),
						text: '我的',
						//count: 23,
						isDot: false,
						customIcon: false
					},
				]
				this.getHosp()
			},
			async getHosp(){
				let res = await getInfo()
				uni.setStorageSync('userinfo',{'permissions':res.permissions,'roles':res.roles,'user':res.user})
				//console.log(res,'hosp');
			},
			switchBar(e) {
				this.current = e
				console.log(e);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		.u-page {}
	}
</style>